<?php
/**
 * Continue
 *
 * Used within looping structures to skip the rest of the current loop
 * iteration and continue execution at the condition evaluation and
 * then the beginning of the next iteration.
 *
 * 'continue' accepts an optional numeric argument which tells it how many
 * levels of enclosing loops it should skip to the end of.
 *
 * @author  Badrus Said <badrus.said@gmail.com>
 * @since   gop1.0
 */
final class gop_Continue extends gop_Base {
    public function execute(gop_Base $_caller = null) {
        if ($this->getReturn()) return;
        $this->setCaller($_caller);
        $caller = $this->getCaller();
        while($caller) {
            if ($caller instanceof gop_BaseIterator) {
                $B = $this->nestedLevel;
                $L = ($this->getContext()->hasCallee($B)) ?
                      $this->getContext()->getCallee($B)->execute() : (int)$B;
                $caller->interupt(0, $L);
                break;
            }
            $caller = $caller->getCaller();
        }
    }
}
?>